package com.example.monitoringsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.monitoringsystem.bean.Medicine;
import com.example.monitoringsystem.bean.Prescription;
import com.example.monitoringsystem.mapper.MedicineMapper;
import com.example.monitoringsystem.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class MedicineServiceImpl implements MedicineService {
    @Autowired
    private MedicineMapper medicineMapper;

    @Override
    public List<Medicine> showAllMedicine() {
        List<Medicine> medicines = medicineMapper.selectList(null);
        return medicines;
    }

    //根据处方里面的id查询药物信息
    @Override
    public Medicine showMedicine(Prescription prescription){
        QueryWrapper<Medicine> wrapper = new QueryWrapper<>();
        wrapper.eq("medicine_id",prescription.getMedicineId());
        Medicine medicine = medicineMapper.selectOne(wrapper);
        return medicine;
    }

}
